from airflow.models import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime
import pytz
tz = pytz.timezone('Asia/Dubai')
def localize_utc_tz(d):
return tz.fromutc(d)
default_args = {
'start_date': datetime(2017, 11, 8),
}
dag = DAG(
'plus_4_utc',
default_args=default_args,
schedule_interval='0 20 * * *',
user_defined_filters={
'localtz': localize_utc_tz,
},
)
task = BashOperator(
task_id='task_for_testing_file_log_handler',
dag=dag,
bash_command='echo UTC {{ ts }}, Local {{ execution_date | localtz }} next {{ next_execution_date | localtz }}',
)